from base.baseBage import basePage
from common.base_driver import init_driver
from selenium.webdriver.common.by import By
from page.lifePage import LifePage
from time import sleep
class BusinessHomepage(basePage):
    guige_box="选规格"
    tianjai_box="添加到购物车"
    Choose_card_box="测试公务卡(5047)"
    confirm_the_Payment_box="确认支付"

    def click_specifications(self):
        '''点击选规格'''
        return self.find_uiautomator(self.guige_box,instance=1).click()
    def click_shopping_cart(self):
        '''点击添加到购物车'''
        return self.find_uiautomator(self.tianjai_box).click()
    def click_settlement(self):
        '''点击结算'''
        return self.touch_tap(800,1550)

    def click_submit_orders(self):
        '''点击下单'''
        return self.touch_tap(800,1550)
    def click_card(self):
        '''选择生活卡'''
        return self.find_uiautomator(self.Choose_card_box).click()
    def slide_toUp_page(self):
        '''滑动屏幕'''
        return self.slide_toUp()
    def click_Payment(self):
        '''点击确认支付'''
        return self.find_uiautomator(self.confirm_the_Payment_box).click()
    def input_password(self):
        '''输入密码'''
        for i in range(6):
            sleep(0.2)
            self.touch_tap(145, 1150)
    def PlaceOrder_TheStore(self):
        '''店内下单'''
        self.click_specifications()
        sleep(0.5)
        self.click_shopping_cart()
        sleep(0.5)
        self.click_settlement()
        sleep(0.5)
        self.click_settlement()
        sleep(1)
        self.click_submit_orders()
        sleep(2)
        self.slide_toUp_page()
        sleep(1)
        self.click_Payment()
        sleep(0.5)
        self.input_password()


if __name__ == '__main__':
    LP=BusinessHomepage()
    RE=LifePage()
    RE.find_uiautomator("进入应用").click()
    sleep(2)
    RE.search_business()
    RE.imput_search_business()
    RE.touch_tap(800,250)
    RE.find_uiautomator("粉之都",instance=1).click()
    LP.PlaceOrder_TheStore()

